package com.uwntek.struts2.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.uwntek.pojo.Projectinfo;
import com.uwntek.service.IProjectService;

public class ProjectAction extends ActionSupport{

	private IProjectService<Projectinfo> projectService;
	private Projectinfo projectinfo;
	public List<Projectinfo> projectList = new ArrayList<Projectinfo>();
	public String remoteUrl;
	private boolean flag =false;
	public String add() throws Exception {
		projectService.create(projectinfo);
		return list();
	}

	public String list() throws Exception {
		// projectList = projectService.list(" from Projectinfo ", 0,
		// Integer.MAX_VALUE,null);
		projectList = projectService.getProjectList(projectinfo
				.getProjectId(), projectinfo.getProjectName());
		
		projectList = projectService.getDesList(projectList, projectinfo);
		if (projectList.size() == 1) {
			projectinfo = projectList.get(0);
			return "list_re";
		} else {
			return "list";
		}
	}
	public Projectinfo getProjectinfo() {
		return projectinfo;
	}

	public void setProjectinfo(Projectinfo projectinfo) {
		this.projectinfo = projectinfo;
	}

	public IProjectService<Projectinfo> getProjectService() {
		return projectService;
	}

	public void setProjectService(IProjectService<Projectinfo> projectService) {
		this.projectService = projectService;
	}

	public List<Projectinfo> getProjectList() {
		return projectList;
	}

	public void setProjectList(List<Projectinfo> projectList) {
		this.projectList = projectList;
	}

	public String getRemoteUrl() {
		return remoteUrl;
	}

	public void setRemoteUrl(String remoteUrl) {
		this.remoteUrl = remoteUrl;
	}
	

}
